﻿//-------------------------------------------------------------------------------------------
// <copyright file="TrustLineViewModel.cs" company="Russell Wilkins">
//     Copyright (c) Russell Wilkins 2014. All Rights Reserved.
// </copyright>
// <author>Russell Wilkins</author>
// <license href="license.txt">
//     The use of this software is governed by the Microsoft Public License
//     which is included with this distribution.
// </license>
//-------------------------------------------------------------------------------------------
namespace Ripple.TestClient.ViewModels
{
    using Ripple.Data;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;

    /// <summary>
    /// TODO: Describe the class
    /// </summary>
    public class TrustLineViewModel : ViewModel<TrustLine>
    {
        public static readonly DependencyProperty AccountIdProperty = DependencyProperty.Register("AccountId", typeof(string), typeof(TrustLineViewModel), new PropertyMetadata(string.Empty));
        public static readonly DependencyProperty BalanceProperty = DependencyProperty.Register("Balance", typeof(double), typeof(TrustLineViewModel), new PropertyMetadata((double)0));
        public static readonly DependencyProperty CurrencyProperty = DependencyProperty.Register("Currency", typeof(string), typeof(TrustLineViewModel), new PropertyMetadata(string.Empty));
        public static readonly DependencyProperty LimitProperty = DependencyProperty.Register("Limit", typeof(double), typeof(TrustLineViewModel), new PropertyMetadata((double)0));
        public static readonly DependencyProperty PeerAccountIdProperty = DependencyProperty.Register("PeerAccountId", typeof(string), typeof(TrustLineViewModel), new PropertyMetadata(string.Empty));
        public static readonly DependencyProperty PeerLimitProperty = DependencyProperty.Register("PeerLimit", typeof(double), typeof(TrustLineViewModel), new PropertyMetadata((double)0));
        public static readonly DependencyProperty QualityInProperty = DependencyProperty.Register("QualityIn", typeof(uint), typeof(TrustLineViewModel), new PropertyMetadata((uint)0));
        public static readonly DependencyProperty QualityOutProperty = DependencyProperty.Register("QualityOut", typeof(uint), typeof(TrustLineViewModel), new PropertyMetadata((uint)0));

        /// <summary>
        /// Initializes a new instance of the TrustLineViewModel class.
        /// </summary>
        public TrustLineViewModel(TrustLine trustLine)
        {
            this.Model = trustLine;
        }

        public string AccountId
        {
            get { return (string)GetValue(AccountIdProperty); }
            set { SetValue(AccountIdProperty, value); }
        }

        public double Balance
        {
            get { return (double)GetValue(BalanceProperty); }
            set { SetValue(BalanceProperty, value); }
        }

        public string Currency
        {
            get { return (string)GetValue(CurrencyProperty); }
            set { SetValue(CurrencyProperty, value); }
        }

        public double Limit
        {
            get { return (double)GetValue(LimitProperty); }
            set { SetValue(LimitProperty, value); }
        }

        public string PeerAccountId
        {
            get { return (string)GetValue(PeerAccountIdProperty); }
            set { SetValue(PeerAccountIdProperty, value); }
        }

        public double PeerLimit
        {
            get { return (double)GetValue(PeerLimitProperty); }
            set { SetValue(PeerLimitProperty, value); }
        }

        public uint QualityIn
        {
            get { return (uint)GetValue(QualityInProperty); }
            set { SetValue(QualityInProperty, value); }
        }

        public uint QualityOut
        {
            get { return (uint)GetValue(QualityOutProperty); }
            set { SetValue(QualityOutProperty, value); }
        }

        protected override void RefreshData()
        {
            this.AccountId = this.Model.AccountId;
            this.Balance = this.Model.Balance;
            this.PeerAccountId = this.Model.PeerAccountId;
            this.Currency = this.Model.Currency;
            this.Limit = this.Model.Limit;
            this.PeerLimit = this.Model.PeerLimit;
            this.QualityIn = this.Model.QualityIn;
            this.QualityOut = this.Model.QualityOut;
        }
    }
}